<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * @version $Id: show_report.tpl.php 1126 2008-06-09 05:45:04Z julienv $
 * @package Joomleague
 * @copyright Copyright (C) 2007  JoomLeague
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see _joomleague_license.txt
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 

$events_config=array(
		"use_tabs_events"=>1);
?>
<div id="joomleague">
<div class="componentheading"><?php echo $htmlHelper->showTitle($joomleague, $overall_config['project_heading_type']); ?></div>
<!-- Header Ende -->

<div id="jlg_matchreport">
<table width="100%" class="contentpaneopen">
	<tr>
		<td class="contentheading"><?php echo _JL_REPORT.' - '.$round->name;?></td>
	</tr>
</table>
<!-- Bereichs�berschrift Ende -->

<br />

<?php 
// get teams info
$teams = $match->getTeams();  

// match results
if (is_null($match->matchpart1_result_decision)) {
  $e1=$match->matchpart1_result;
} 
else {
  $e1=$match->matchpart1_result_decision;
}
if (is_null($match->matchpart2_result_decision)) {
  $e2=$match->matchpart2_result;
} 
else {
  $e2=$match->matchpart2_result_decision;
}
?>

<table id="jlg_resulttable" width="96%" align="center" border="0" cellpadding="5" cellspacing="0">
  <tr>
    <th colspan="2" style="text-align:center;">
      <?php echo mosFormatDate($match->match_date, _JL_MATCHDAYDATE." - %R "._JL_CLOCK, 0);?>
    </th>
  </tr>
  <tr>
    <td align="center" width="50%"><?php echo $matchpart_pics[0];?></td>
    <td align="center" width="50%"><?php echo $matchpart_pics[1];?></td>
  </tr>
  <tr>
    <td align="center"><b><br /><?php echo $teams[0]->name;?></b></td>
    <td align="center"><b><br /><?php echo $teams[1]->name;?></b></td>
  </tr>
  <tr>
    <td align="center"><h1><b><br /><?php echo $e1;?></b></h1></td>
    <td align="center"><h1><b><br /><?php echo $e2;?></b></h1></td>
  </tr>
</table>
<?php
if ($match->crowd > 0 || $match->referee_id > 0) 
{ 
  ?> 
  <br />
  <table id="jlg_refereetable" width="96%" align="center" border="0" cellpadding="5" cellspacing="0">
    <tr>
    <?php if ($match->crowd > 0) 
    { 
      ?>
      <td><b><?php echo _JL_REPORT_CROWD;?></b><?php echo number_format($match->crowd,0,',','.');?>
      </td>
      <?php 
    } 
    if ($match->referee_id > 0) 
    { 
      ?>
      <td style="text-align:right;"><b><?php echo _JL_REPORT_REFEREE;?></b>
        <?php
        if ($joomleague->teams_as_referees) echo $referee->name;
        else echo $referee->firstname." ".$referee->lastname;
        ?>
      </td>
      <?php 
    }
    ?>
    </tr>
  </table>
  <br />
  <?php 
}

// Start of tean roster / substitutions
  if ($show_roster) {
  ?> 
  <br />
  <table id="jlg_rostertable" width="96%" align="center" border="0" cellpadding="5" cellspacing="0">
    <tr>
      <td class="contentheading" colspan="2"><?php echo _JL_STARTING_ROSTERS;?></td>
    </tr>
    <tr>
      <?php
      $homeroster='<div class="jlg_roster">';
      $awayroster='<div class="jlg_roster">';
      foreach ($positions AS $pos) 
      {
        if (isset($sortedhome[$pos->id])) 
        {
          // Home Roster    
          if (count($sortedhome[$pos->id])>0) 
          {
            $homeroster .= "<div class='jlg_posname'>$pos->name</div>";          
            $homeroster .= '<ul>';
            foreach ($sortedhome[$pos->id] AS $player_id) 
            {
              $player=new Player($joomleague->_db);
              $player->load($player_id);
              $homeroster .= "<li><a href=\"".sefRelToAbs(JL_COMPONENT_LINK."&amp;func=showPlayer&amp;p=".$joomleague->id."&amp;pid="
                .$player_id.JL_ITEMID_SUFFIX)."\">";
              $homeroster .= $player->lastname.", ".$player->firstname;
              $homeroster .= "</a></li>";
            }
            $homeroster .= '</ul>';
          }
          // Away roster
          if (count($sortedaway[$pos->id])>0) 
          {
            $awayroster .= "<div class='jlg_posname'>$pos->name</div>";
            $awayroster .= "<ul>";
            foreach ($sortedaway[$pos->id] AS $player_id) {
              $player=new Player($joomleague->_db);
              $player->load($player_id);
              $awayroster .= "<li><a href=\"".sefRelToAbs(JL_COMPONENT_LINK."&amp;func=showPlayer&amp;p=".$joomleague->id."&amp;pid="
                .$player_id.JL_ITEMID_SUFFIX)."\">";
              $awayroster .= $player->lastname.", ".$player->firstname;
              $awayroster .= "</a></li>";
            }
            $awayroster .= "</ul>";
          }
        }
      }
      $homeroster .="</div>";
      $awayroster .="</div>";
      ?>
      <td width="50%" valign="top">
        <?php echo $homeroster;?>
  		</td>
    	<td valign="top" width="50%">
        <?php echo $awayroster;?>
  		</td>
  	</tr>
  	<!--  END of Team roster -->
<?php
}

$came_in = $match->getSubstitutes();
if (count($came_in[$match->matchpart1]) > 0 || count($came_in[$match->matchpart2]) > 0) { 
?>
  	<!-- START of Substitutions -->
  	<tr>
  	  <td  class="contentheading" colspan="2"><?php echo _JL_IN_OUT;?></td>
  	</tr>
  	<tr>
  	  <td valign="top"  width="50%">
      <?php
      
      if (count($came_in[$match->matchpart1]) > 0) {  
        echo $htmlHelper->format_substitutes($came_in[$match->matchpart1], $config);
      }
      ?>
  	  </td>
    	<td valign="top" width="50%">
      <?php
      if (count($came_in[$match->matchpart2]) > 0) {
        echo $htmlHelper->format_substitutes($came_in[$match->matchpart2], $config);
      }
      ?>
  	  </td>
    </tr>
    <!--  END of Substitutions -->
<?php
}
?>
	</table>
  <?php 



// match decision
if ($match->decision_info != '') 
{
  ?>
  <table id="jlg_decisiontable" width="96%" align="center" border="0" cellpadding="5" cellspacing="0">
    <tr><td align="center"><i><?php echo $match->decision_info;?></i></td></tr>
  </table>
  <?php
}

// match events
if ($joomleague->areThereEvents($match->match_id, 0) > 0 || $match->match_result_detail!='')
{
	?>
  <br />
  <table id="jlg_eventstable" width="96%" align="center" border="0" cellpadding="5" cellspacing="0">
    <tr>
      <td class="contentheading"><?php echo _JL_SEF_EVENTS;?></td>
    </tr>
    <tr>
      <td width="96%">
      <?php
      $htmlHelper->show_events_container_in_results($match, 'block', $events_config, 0);
      ?>
      </td>
    </tr>
  </table>
  <?php
}

// match summary
if ($match->summary != '') 
{
  ?> 
  <br />
  <table id="jlg_summarytable" width="96%" align="center" border="0" cellpadding="5" cellspacing="0">
  	<tr>
      <td class="contentheading" width="96%"><?php echo _JL_REPORT_DETAIL;?></td>			
  	</tr>
  	<tr>
      <td><?php echo $htmlHelper->makemambots ( $match->summary );?></td>
    </tr>
  </table>
  <?php 
}
?>
</div>
<!-- Inhalt Ende -->

<!-- Print Back Button START -->
<?php 
if ( $overall_config['show_back_button'] > 0 ) 
{
    if ( $overall_config['show_back_button'] == '1' ) {
        echo '<div align="left">';
    }
    else {
        echo '<div align="right">';
    }
    $params = new mosParameters( '' );
    $params->def( 'back_button', true );
    $params->def( 'popup', false );
    mosHTML::BackButton( $params );
    echo '</div>';
}
?>
<!-- Print Back Button END -->
</div>